package com.zyc.demo.v.controller;

import com.zyc.demo.v.service.CommonService;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.util.StreamUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import tk.mybatis.mapper.annotation.RegisterMapper;

import java.io.InputStream;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Map;

/**
 * @author: zyc
 */
@RestController
@RequestMapping("/common")
public class CommonController {

    @Autowired
    CommonService commonService;

    @RequestMapping("/page")
    public Object page(@RequestParam(defaultValue = "1") int pageNum,
                       @RequestParam(defaultValue = "10") int pageSize) {

        return commonService.page(pageNum, pageSize);
    }

    public static void main(String[] args) throws Exception {
        URL         url         = new URL("https://www.google.com/");
        InputStream inputStream = url.openConnection(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("127.0.0.1", 19181))).getInputStream();
        String      res         = StreamUtils.copyToString(inputStream, StandardCharsets.UTF_8);
        System.out.println(res);
    }
}


